package com.bdmc.smokesensor.Utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * 全局常量
 */
@Component
public class Constants {

    public static String APPID;

    public static String APPSECRET;

    public static int INTERVAL;

    public static int EXPIREMIN;

    public static int SHORTMSGAPPID;

    public static String SHORTMSGAPPKEY;

    @Value("${wechat.appid}")
    public void setAppid(String appid) {
        APPID = appid;
    }

    @Value("${wechat.appsecret}")
    public void setAppsecret(String appsecret) {
        APPSECRET = appsecret;
    }

    @Value("${wechat.validate.Interval}")
    public void setInterval(int interval) {
        INTERVAL = interval;
    }

    @Value("${wechat.validate.expiredMin}")
    public void setExpiredMin(int expiredMin) {
        EXPIREMIN = expiredMin;
    }

    @Value("${shortMsg.appid}")
    public void setShortMsgAppid(int shortmsgAppid) {
        SHORTMSGAPPID = shortmsgAppid;
    }

    @Value("${shortMsg.appkey}")
    public void setShortMsgAppkey(String shortmsgAppkey) {
        SHORTMSGAPPKEY = shortmsgAppkey;
    }

    public static int getSmsTemplateid(String rawData) {     
        int tp_id = 0;
        if (rawData.indexOf("020100")!=-1) {//火警
            tp_id = 265407;
        } else if (rawData.indexOf("020200")!=-1 || rawData.indexOf("020300")!=-1) {//故障
            tp_id = 269186;
        } else if (rawData.indexOf("020400")!=-1||rawData.indexOf("020700")!=-1) {//清除火警
            tp_id = 268979;
        } else if (rawData.indexOf("0099")!=-1) {//离线
            tp_id = 268981;
        }else if(rawData.indexOf("020A00")!=-1){//拆除
            tp_id=268983;
        }
        
        return tp_id;
    }

    public static int getVoiceTemplateid(String rawData) {
        int tp_id = 0;
        if (rawData.indexOf("020100")!=-1) {//火警
            tp_id = 265409;
        } else if (rawData.indexOf("020200")!=-1 || rawData.indexOf("020300")!=-1) {//故障
            tp_id = 269187;
        } else if (rawData.indexOf("020400")!=-1||rawData.indexOf("020700")!=-1) {//清除火警
            tp_id = 268984;
        }else if(rawData.indexOf("020A00")!=-1){//拆除
            tp_id = 268988;
        }else if(rawData.indexOf("0099")!=-1){//离线
            tp_id = 268987;
        }
        return tp_id;
    }
}
